package com.pattern.design.Chapter_2.com.devchronicles.basicsofj2ee;

import java.util.Map;
import java.util.HashMap;

import javax.annotation.PostConstruct;
import javax.ejb.Singleton;
import javax.ejb.Startup;

@Startup
@Singleton
public class CacheSingletonBean {
	private Map<Integer, String> myCache;

	@PostConstruct
	public void start() {
		myCache = new HashMap<Integer, String>();
	}

	public void addUser(Integer id, String name) {
		myCache.put(id, name);
	}

	public String getName(Integer id) {
		return myCache.get(id);
	}
}
